package cn.iocoder.yudao.module.ems.dal.mysql.maintaintask;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ems.dal.dataobject.maintaintask.MaintainTaskDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.ems.controller.admin.maintaintask.vo.*;

/**
 * 保养任务 Mapper
 *
 * @author 左达成
 */
@Mapper
public interface MaintainTaskMapper extends BaseMapperX<MaintainTaskDO> {

    default PageResult<MaintainTaskDO> selectPage(MaintainTaskPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MaintainTaskDO>()
                .eqIfPresent(MaintainTaskDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MaintainTaskDO::getEquipmentId, reqVO.getEquipmentId())
                .eqIfPresent(MaintainTaskDO::getStandardId, reqVO.getStandardId())
                .betweenIfPresent(MaintainTaskDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(MaintainTaskDO::getId));
    }

    default List<MaintainTaskDO> selectList(MaintainTaskExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MaintainTaskDO>()
                .eqIfPresent(MaintainTaskDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MaintainTaskDO::getEquipmentId, reqVO.getEquipmentId())
                .eqIfPresent(MaintainTaskDO::getStandardId, reqVO.getStandardId())
                .betweenIfPresent(MaintainTaskDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(MaintainTaskDO::getId));
    }

}
